package com.masterclient.app.businessmodule.vipmodule.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.eoner.baselib.widget.navgation.FCNavigationBar;
import com.eoner.baselibrary.widget.CommonTabLayout;
import com.masterclient.app.R;
import com.masterclient.app.base.FCBusinessActivity;
import com.masterclient.app.businessmodule.vipmodule.adapter.FragmentAdapter;
import com.masterclient.app.businessmodule.vipmodule.fragment.OrderFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 售后订单管理
 */
public class ServiceOrderActivity extends FCBusinessActivity {
    @BindView(R.id.tabLayout)
    CommonTabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    @Override
    protected int requireGetLayoutId() {
        return R.layout.activity_sale_order;
    }

    @Override
    protected void requireSetCustomNavigationBar(FCNavigationBar navigationBar) {
        navigationBar.setTitle("售后");
    }

    @Override
    protected void requireInitUIAndData(Bundle savedInstanceState) {
        initFragment();
    }

    /**
     * 初始化fragment
     */
    private void initFragment() {
        List<Fragment> fragments = new ArrayList<>();
        List<String> tabs = new ArrayList<>();
        tabs.add("全部");
        tabs.add("待审核");
        tabs.add("待买家退货");
        tabs.add("待卖家收货");
        tabs.add("待退款");
        tabs.add("退款成功");
        tabs.add("已关闭");
        List<String> status = new ArrayList<>();
        status.add("");
        status.add("0");
        status.add("2");
        status.add("3");
        status.add("5");
        status.add("6");
        status.add("9");
        for (int i = 0; i < tabs.size(); i++) {
            tabLayout.addTab(tabs.get(i), i == 0);
            fragments.add(OrderFragment.newInstance(1, status.get(i)));
        }

        FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), fragments, tabs);
        viewPager.setAdapter(adapter);
        viewPager.addOnPageChangeListener(new TabLayout.
                TabLayoutOnPageChangeListener(tabLayout.getTabLayout()));
        tabLayout.setupWithViewPager(viewPager);
    }


}
